package com.zpark.controller;

import com.zpark.beans.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
//@restcontroller它是@controller+@ResponseBody两个注解的结合
@RestController
@RequestMapping("/config")
public class ConfigController {
    // 自动注入
    @Autowired
    private Person person;

    //使用value注解获取配置
    @Value("${server.port}")//spEl表达式
    private String port;
    //responsebody声明当前方法返回json格式数据
    @ResponseBody
    @RequestMapping("/person")
    public Person getPerson(){
        return person;
    }
    @RequestMapping("/port")
    public String getPort(){
        return port;
    }
}
